<?php
include ("Images.php"); 
class ImageGrabber 
{
	private $Destination;
	private $ResizeToX;
	private $ResizeToY;
	private $Image;
	
	function __construct($Destination, $ResizeToX = 0, $ResizeToY = 0)
	{
		$this->Destination = $Destination;
		$this->Image = new SimpleImage(); 
        $this->ResizeToX = $ResizeToX;
        $this->ResizeToY = $ResizeToY;
	}
	
	
	/**
	 * @return string  
	 */
	function Grab($Url)
	{
	   $this->Image->load($Url);
	   	
	   if ($this->ResizeToX)
	   $this->Image->resizeToHeight($this->ResizeToX);
	   $Ext = pathinfo($Url);
	   $Ext = $Ext['extension'];
	   $NewName = md5(microtime()) . "." . $Ext;
	   $this->Image->save($this->Destination . "/" . $NewName);
	   return $NewName;
	}
}